package role

import (
	"parking-lot-go-admin/controller"
	"parking-lot-go-admin/model"
	"parking-lot-go-admin/model/admin"

	"github.com/gin-gonic/gin"
)

func InsertRole(c *gin.Context) {
	requestDataStruct := struct {
		Name string `json:"name"`
	}{}

	c.ShouldBindJSON(&requestDataStruct)

	var adminGroupStruct admin.AdminGroupStruct
	if err := model.CreateModelData(
		model.Db,
		adminGroupStruct.TableName(),
		map[string]interface{}{
			"name": requestDataStruct.Name,
		},
	); err != nil {
		controller.Fail(c, err.Error())
		return
	}

	controller.Success(c, "")
}
